home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Classes / ObjDB / ObjDB.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-30  |  4.1 KB  |  173 lines

  1. /*****
  2.  * ObjDB.h
  3.  *
  4.  *     class for a data base object.
  5.  *
  6.  *****/
  7.  
  8. #define    _H_ObjDB        /* Include this file only once */
  9. #import    <objc/Object.h>
  10. #import <objc/Storage.h>
  11. #include <stdio.h>
  12. #define VERSION 1001
  13. #define BUFFSIZE 1024 
  14. #define ISNTYPE int
  15. #define ISNSIZE    sizeof(ISNTYPE)
  16. #define ISNRECSIZE 2
  17. #define NUM_ISNS BUFFSIZE/ISNSIZE
  18.  
  19.     typedef    struct     {
  20.         int     blk;
  21.         int        offset;
  22.             }  loc;
  23.                 
  24.     typedef struct    {
  25.         char key_value[24];
  26.         int count;
  27.         int    first_isn;
  28.             }    KEY_VALUE;
  29.  
  30.     typedef    struct    {
  31.         int        display_len;
  32.         char    abbrev[3];
  33.         char    kind;
  34.         char    name[16];
  35.         char    keyed;
  36.         char    edit_mask[12];
  37.         Storage    *hash;            /*    Stores key values        */
  38.         Storage *key_isns;        /*    Stores key isn_tables    */
  39.         } FIELD;    
  40.  
  41. typedef        struct  {
  42.         FILE        *ptr;
  43.         int blks;
  44.         int rover;        } file_data;
  45.  
  46. typedef struct    {
  47.     char    dBaseName[100];
  48.     file_data data_file    ;
  49.     int max_isns;
  50.     int max_keys;
  51.     int num_keys;
  52.     int last_isn;
  53.     float data_frac;
  54.     int    journal_flag;
  55.     int    reuse_isns;
  56.     int    use_wrk_file;
  57.     int dump_date;
  58.     int dump_time;
  59.     int report_block;
  60.     int buff_size;
  61.     int version;
  62.     int nbuf;
  63.         } DBINFO;
  64.         
  65. typedef struct {
  66.     int block;
  67.     int    update;
  68.     int count;
  69.     char data[BUFFSIZE];
  70.         } BUFFER;
  71.  
  72. typedef    struct    {
  73.         int l;
  74.         int *fld;
  75.         int *ofset;
  76.         }    fld_index;
  77.     
  78. /*    function prototypes */
  79.     void *malloc(), *calloc(), *free(), *exit(), *system(), *close();
  80.     char *strcpy(), *strcat(), *index();
  81.     int writeRandom(), readRandom();
  82.     int strcmp(), get_num(), strlen(), min(), mod(), max(), atoi(), atol();
  83.     int strncmp(), get_reclen(), get2(), memcpy(), loc_fld(), nxtisn();
  84.     int strcasecmp(), gn_I_fld(), gn_L_fld(), gn_A_fld(), errMsg();
  85.     
  86.  
  87.  
  88. /*    Public    */
  89.  
  90. @interface ObjDB : Object
  91.  
  92. {
  93.     Storage        *myDFD, *storInfo, *isnTable, *spaceTable, *buffers;
  94.     DBINFO        *myInfo;
  95.     BUFFER        *buffer;
  96.     int            cacheHits, cacheCalls, cacheWrites;
  97.     int            *Last,    *Isns, *Hold;
  98.     char        space_table_desc[128];
  99.     char        buffer_desc[128];
  100.     char        isns_desc[128];
  101.     char        field_desc[128];
  102.     char        hash_desc[128];
  103.     char        storage_desc[128];
  104. }
  105.  
  106. - init: (char *)dbname data_use_fraction: (float)dFraction;
  107. - close;
  108. - free;
  109. - awake;
  110. - status;
  111. - setDescriptors;
  112. - prtCacheStats;
  113. - prtStructure;
  114. - prtRecAtIsn:(int)isn;
  115. - (int)numberFlds;
  116. - addFldDesc:(FIELD *)aFld;
  117. - (FIELD *)getFldDesc:(int)theFldNum;
  118. - (int)getFldNumForAbbrev:(char *)fldAbbrev;
  119. - loadDFD:(FILE *)file;
  120. - (char *)getBlk:(int) blkreq;
  121. - (BUFFER *)newBlk:(int) blkreq;
  122. - (BUFFER *)locBlk:(int) blkreq;
  123. - updBuf:(int)block;
  124. - keyRecord:(int)isn;
  125. - deKeyRecord:(int)isn;
  126. - keyFld:(char *)abbrev;
  127. - keyFld:(int)fldNum forIsnNum:(int)isn;
  128. - (int)addrec:(int)blkno:(int)isn:(char *)source:(char *)descript;
  129. - (fld_index *)bldFldIndex:(char *)descript;
  130. - (int)addData:(char *)source:(char *)descript;
  131. - getData:(char *)source atIsn:(int)isn describedBy:(char *)descript;
  132. - (int)updateDataAtIsn:(int)isn with:(char *)data describedBy:(char *)description;
  133. - deleteDataAtIsn:(int)isn;
  134. - (int)updrec:(int)blkno:(int)isn:(char *)source:(char *)descript:(char *)old_buffer;
  135. - (int)delrec:(int)blkno:(int)isn:(char *)tmp_buffer;
  136. - setIsn:(int)isn ToBlock:(int)block;
  137. - (int)getBlockwithIsn:(int)isn;
  138. - (int)geta_isn;
  139. - newIsnBlock;
  140. - (int)numberIsns;
  141. - (int)numKeyedFlds;
  142. - (int *)getIsnListforField:(char *)abbrev value:(char *)value;
  143. - (int *)getIsnListforField:(char *)abbrev value:(char *)value operator:(char *)oper;
  144. - listKeysForField:(char *)abbrev;
  145. - prtKeyTableFor:(char *)abbrev;
  146. - addKey:(char *)value isnNo:(int)isn field:(FIELD *)myField;
  147. - (int)findKey:(char *)value field:(FIELD *)myField;
  148. - deleteKey:(char *)value isnNo:(int)isn field:(FIELD *)myField;
  149. - setKeyField:(char *)abbrev;
  150. - unKeyField:(int)fldNum;
  151. - unKeyDB;
  152. - keyDB;
  153. - (int *)newList:(int)size;
  154. - (int *)pushList:(int)size;
  155. - (int *)andIsns;
  156. - (int *)orIsns;
  157. - (int *)xorIsns;
  158. - (int *)notIsns;
  159. - (int *)getIsnList;
  160. - (int)getListCount;
  161. - (int *)getLastList;
  162. - prt_one_status;
  163. - (int)allocSpace: (int)space in:(int) block_allocated;
  164. - (int)findSpace: (int)space :(float)data_frac; 
  165. - dumpSpace;
  166. - dumpIsns;
  167. - dumpIsns:(int *)isns toFile:(char *)dump_file_name;
  168. - (int)loadDB:(FILE *)fptr:(char *)desc_str:(char *)data_str:(char)delim;
  169. - loadDBfromFile:(char *)file_name;
  170. - write:(NXTypedStream *)typedStream;
  171. - read:(NXTypedStream *)typedStream;
  172. @end
  173.